<template>
	<view @click="onClick" style="display: flex; flex-diretion: row !important; width: 100%; height: 100%;"  >
        <view>
            <image style="width: 50px;height:50px;"
                   :src="` ${ (!!imgurl &&  0< imgurl.length) ? imgurl : '../../static/icon/png.png'  } `">
            </image>
        </view>
	    <view class="item"   style="width: 80px;height:50px;">
			<text >{{imgurl ?"重拍":"拍照"}}</text>
        </view>
    </view>
</template>
<!--<template>
	<view class="item" @click="onClick" >-->
		<!--<img src="../../static/icon/camera.png" style="width: 50px;height:50px;" :alt="imgurl ? '重拍' : '拍照'"/>-->
		<!--{{imgurl ?"重拍":"拍照"}}
	</view>
</template>-->
<script>
	import {
		registerParamsEvent
	} from "../../common/js/util";
    import {
        getLocal
    } from "../../common/localTools"; // gps 定位
	export default {
		props: {
			purpose: {
				type: String,
				defult: "",
			},
			index: {
				defult: null,
			},
			imgurl: {
				type: String,
				defult: "",
			},
			disabled: {
				defult: false,
			}
        },
        data() {
            return {
                baseurl: ""
            };
        },
		methods: {
            async init() {

                 if (this.needLocal) {
                    const { code, data } = await getLocal();
                        debugger
                    if (code !== "0") {
                        uni.showModal({
                            title: "敬告",
                            content: "由于您未授权位置信息，无法拍照上传..",
                        });
                        return "";
                    }
                    this.localName = data[0].name;
                } else {
                    this.localName = this.local;
                } 


                this.paramsData = {
                    dataId: this.project.id,
                    addressLocal: this.localName,
                    isRecord: "Y",
                    ...this.project,
                };
            },

			onClick() {
                registerParamsEvent((paramKey) => {
                    uni.$emit(paramKey, {
                        purpose: this.purpose,
                        imgurl: this.imgurl,
                        disabled: this.disabled,
                        index: this.index
                    });
                }, "snapArgsInit");

                
                registerParamsEvent((attach) => {
                    this.$emit("snapHandler", attach)
				}, "snapCallback");

                uni.navigateTo({
                    url: "/pages/snapshot/snapDevice"
                });

			}
		}
	};
</script>

<style scoped>
    .item {
        line-height: 46px;
        text-align: center;
        background: #fff;
        border: 2rpx solid #dcdddd;
        border-radius: 15rpx;
        overflow: hidden;
    }
</style>
